import Taro, { Component, Config } from "@tarojs/taro";
import { View, Text, Image, RichText } from "@tarojs/components";
import {IStoreProps} from '../../store/Stores'
import {getRuntime, userSex, subtime, servicePhoneNumber} from '../../utils/common'
import {toJS} from "mobx";
import PageFooterInfo from '../../components/PageFooterInfo'
import Report from '../../components/Report'

import './index.less'
import './page4_detail.less'

import rz from '../../assets/img/icon_28.png'

import {inject, observer} from "@tarojs/mobx";


interface IHomeProps extends IStoreProps {
}

@inject("stores")
@observer
class LawyerDetail extends Component<IHomeProps>{
  constructor(props){
    super(props)
  }

  state = {
    info: {},
    isVip: false,
  }

  componentWillMount(): void {
    Taro.setNavigationBarTitle({title: '项目详情'})
    const id = this.$router.params.id
    this.getProjectInfo(parseInt(id))
    let userInfo = getRuntime().getUserInfo() || {}
    if(userInfo.agencyLevel>0){ this.setState({isVip: true}) }
  }

  getProjectInfo(id:number) {
    let { FinancialCenterStore } = this.props.stores
    FinancialCenterStore.getProjectInfo({
      id,
      callback: res => {
         console.error(res)
        this.setState({
          info: toJS(res)
        })
      }
    })
  }

  config: Config = {
    navigationBarTitleText: '项目详情'
  }

  render() {
    let { info, isVip } = this.state
    return(
      <View className='lawyer-wrap lawyer-detail'>
        <View className='list-03'>
          <View className='list-03-item' >
            <View className='r'>
              <View className={'title'}>{info.projectName}</View>
              <View className={'info'}>
                <Text className={'date'}>{subtime(info.creationTime)}</Text>
                <Text className={'date'}>浏览{info.viewAmount}人</Text>
              </View>
            </View>
          </View>
        </View>
        <View className='interval' />

        <View className='column-title content-30'>
          <Text className='column-name'>项目信息</Text>
        </View>
        <View className='item-lawyer'>
          <View className='line'>
            <Text className='title'>项目类型：</Text>
            <Text className='name'>{info.projectType}</Text>
          </View>
        {/*  <View className='line'>
            <Text className='title'>项目工期：</Text>
            <Text className='name'>{info.eduction}</Text>
          </View>*/}
          <View className='line'>
            <Text className='title'>所在地区：</Text>
            <Text className='name'>{info.area}</Text>
          </View>
          <View className='line'>
            <Text className='title'>项目价格：</Text>
            <Text className='name'>{info.projectPrice}</Text>
          </View>
        </View>
        <View className='interval' />

        <View className='column-title content-30'>
          <Text className='column-name'>企业信息</Text>
        </View>
        <View className='item-lawyer'>
          <View className='line'>
            <Text className='title'>企业名称：</Text>
            {isVip&&<Text className='name'>{info.companyName}</Text>}
            {!isVip&&<View className='name'>
                <Text>*******</Text>
                <Text className='vip'>(VIP会员可见)</Text>
            </View>}
          </View>
          <View className='line'>
            <Text className='title'>企业性质：</Text>
            <Text className='name'>{info.natureOfTheFirm}</Text>
          </View>
          <View className='line'>
            <Text className='title'>企业规模：</Text>
            <View className='name'>
              <Text>{info.enterpriseScale}</Text>
            </View>
          </View>
          <View className='line'>
            <Text className='title'>企业资质：</Text>
            <Text className='name'>{info.enterpriseQualification}</Text>
          </View>
          <View className='line'>
            <Text className='title'>纳税类型：</Text>
            <Text className='name'>{info.taxTypes}</Text>
          </View>
          <View className='line'>
            <Text className='title'>公司地址：</Text>
            {isVip&&<Text className='name'>{info.enterpriseAddress}</Text>}
            {!isVip&&<View className='name'>
                <Text>*******</Text>
                <Text className='vip'>(VIP会员可见)</Text>
            </View>}
          </View>
        </View>
        <View className='interval' />

        <View className='column-title content-30'>
          <Text className='column-name'>备注</Text>
        </View>
        <View className='item-lawyer-desc'>
          {info.remarks}
        </View>
        <View className='interval' />

        <View className='column-title content-30'>
          <Text className='column-name'>联系方式</Text>
        </View>
        <View className='item-lawyer'>
          <View className='line'>
            <Text className='title'>联系人：</Text>
            {isVip&&<Text className='name'>{info.contactsName}</Text>}
            {!isVip&&<View className='name'>
               <Text>*******</Text>
               <Text className='vip'>(VIP会员可见)</Text>
            </View>}
          </View>
          <View className='line'>
            <Text className='title'>联系电话：</Text>
            {isVip&&<Text className='name'>{info.phoneNumnber}</Text>}
            {!isVip&&<View className='name'>
               <Text>*******</Text>
               <Text className='vip'>(VIP会员可见)</Text>
            </View>}
          </View>
          <View className='line'>
            <Text className='title'>微信号：</Text>
            {isVip&&<Text className='name'>{info.wechatNumber}</Text>}
            {!isVip&&<View className='name'>
               <Text>*******</Text>
               <Text className='vip'>(VIP会员可见)</Text>
            </View>}
          </View>
          <View className='line'>
            <Text className='title'>QQ号：</Text>
            {isVip&&<Text className='name'>{info.qqNumber}</Text>}
            {!isVip&&<View className='name'>
               <Text>*******</Text>
               <Text className='vip'>(VIP会员可见)</Text>
            </View>}
          </View>
        </View>
        <View className='interval' />
        <Report />

        <PageFooterInfo info={'投诉举报热线：'+servicePhoneNumber} />

      </View>
    )
  }
}

export default LawyerDetail
